﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GraphTools
{
    public class Edge// : IComparable
    {
        protected static int nextID;

        public int Id { get; protected set; }
        public INode Node1 { get; protected set; }
        public INode Node2 { get; protected set; }

        protected static int GetNextID()
        {
            return nextID++;
        }

        public Edge(INode node1, INode node2) : this(GetNextID(),node1,node2)
        {
        }

        public Edge(int Id, INode node1, INode node2)
        {
            this.Id = Id;
            this.Node1 = node1;
            this.Node2 = node2;
        }

        public bool IsOverlaps(Edge e)
        {
            return ((Node1.Equals(e.Node1) && Node2.Equals(e.Node2)) || (Node1.Equals(e.Node2) && Node2.Equals(e.Node1)));
        }

        public override bool Equals(object obj)
        {
            return IsOverlaps((Edge)obj);
        }

        public override int GetHashCode()
        {
            return Node1.GetHashCode() + Node2.GetHashCode();
        }
    }
}
